//
//  NetAPIManager.m
//  ImGuider
//
//  Created by llt on 2017/4/12.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "NetAPIManager.h"
#import "NetClient.h"
#import "FileManager.h"
#import "AFNetworkActivityIndicatorManager.h"
#import "PhoneInfo.h"

#import "VersionModel.h"

#import "UMessage.h"

#import <AliyunOSSiOS/OSSService.h>
#import "SearchResultModel.h"

#import "PayDAO.h"

#define UMessageGroup @"ImGuider"

@implementation NetAPIManager

//1.1 首页根据坐标获取城市及推荐景点
+ (void)getRecommendScenicWithLocation:(CLLocationCoordinate2D )coordinate andBlock:(void (^)(City *city, NSError *error))block {
    
    NSDictionary *params = @{@"lng": @(coordinate.longitude),@"lat":@(coordinate.latitude)};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"homepage/geo" withParams:params needCache:NO withMethodType:Post autoShowError:NO andBlock:^(id data, NSError *error) {
        
        City *city = [City modelWithJSON:data];
        
        if (block) {
            block(city,error);
        }
        
    }];
}
//1.2 根据城市ID获取城市信息及景点
+ (void)getRecommendScenicWithCityID:(NSNumber *)cityID andBlock:(void (^)(City *city, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"city/%@",cityID] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        City *city = [City modelWithJSON:data];
        
        if (block) {
            block(city,error);
        }
        
    }];
}

//1.20 获取当前坐标获所在城市名
+ (void)getGpsCityBlock:(void (^)(City *city, NSError *error))block {
    
    CLLocationCoordinate2D coor = transformFromGCJToWGS([LocationManager sharedManager].currentLocation.coordinate, nil);
    
    NSDictionary *params = @{@"lng": @(coor.longitude),@"lat":@(coor.latitude)};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"gpscity" withParams:params needCache:NO withMethodType:Post autoShowError:NO andBlock:^(id data, NSError *error) {
        
        City *city = [City modelWithJSON:data];
        
        if (block) {
            block(city,error);
        }
        
    }];
}


//0.1 获取版本号
+ (void)getAppVersionBlock:(void (^)(id data, NSError *error))block {
    
    [[NetClient sharedClient]requestJsonDataWithPath:@"version" withParams:nil needCache:YES withMethodType:Get autoShowError:NO andBlock:^(id data, NSError *error) {
        
        VersionModel *versionModel = [VersionModel modelWithJSON:data];
        
        if (versionModel) {
            [AppManager sharedManager].version = versionModel;
            
            [[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateApp" object:nil];
        }
        
        if (block) {
            block(@"success",error);
        }
        
    }];
}
//1.3 获取上架所有城市信息
+ (void)getOnlinecitiesWithBlock:(void (^)(NSArray * onlinecountry, NSError * error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"allcities" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            
            if (block) {
                block(nil,error);
            }
            return;
        }
        
        NSArray *onlinecountry = [NSArray modelArrayWithClass:[Country class] json:data[@"countries"]];
        
        if (block) {
            
            block(onlinecountry, error);
        }
    }];
}
//0.2 获取所有国家列表
+ (void)getAllcountryWithBlock:(void (^)(NSArray * allcountry, NSError * error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"country/alllist" withParams:@{} needCache:YES withMethodType:Post autoShowError:YES andBlock:^(NSDictionary *data, NSError *error) {
        
        if (error) {
            return;
        }
        
        NSArray *allcountry = [NSArray modelArrayWithClass:[Country class] json:data[@"country"]];
        
        if (block) {
            block(allcountry,error);
        }
    }];
}
//1.4 获取城市下的景点
+ (void)getAllViewsWithCity:(NSNumber *)cityID start:(NSNumber *)start count:(NSNumber *)count block:(void (^)(NSArray *viewsArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"city/%@/views/v13",cityID] withParams:@{@"pageno":start,@"pagesize":count} needCache:YES  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *resultArray = [NSArray modelArrayWithClass:[Scenic class] json:data[@"content"]];
        
        if (block) {
            block (resultArray, error);
        }
    }];
}
//1.6 城市导览列表
+ (void)getAllLinesBy:(NSNumber *)cityID start:(NSNumber *)start count:(NSNumber *)count block:(void (^)(NSArray *, NSError *))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"city/%@/lines",cityID] withParams:@{@"pageno":start,@"pagesize":count} needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *lineArray = [NSArray modelArrayWithClass:[LineModel class] json:data[@"content"]];
        if (block) {
            block (lineArray, error);
        }
    }];
}
//1.5 获取城市导游名片
+ (void)getAllGuiderBy:(NSNumber *)cityID start:(NSNumber *)start count:(NSNumber *)count block:(void (^)(NSArray *, NSError *))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"city/%@/guiders",cityID] withParams:@{@"pageno":start,@"pagesize":count} needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *guiderArray = [NSArray modelArrayWithClass:[GuiderModel class] json:data[@"content"]];
        
        if (block) {
            block (guiderArray, error);
        }
    }];
}
//1.7 导游信息
+ (void)getGuiderDetailWith:(NSString *)guiderid cityid:(NSString *)cityid block:(void (^)(GuiderModel *guider, NSError *error))block {
    
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    
    if (cityid) {
        [parmas setValue:cityid forKey:@"cityid"];
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/guider/%@",guiderid] withParams:parmas needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        GuiderModel *guiderModel = [GuiderModel modelWithJSON:data];
        
        if (block) {
            block (guiderModel, error);
        }
        
    }];
    
}
//1.8 景点及导游信息
+ (void)getScenicGuiderListWithScenticID:(NSString *)scenicID Block:(void (^)(Scenic *scenic, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"viewandguides/%@/v2",scenicID] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        Scenic *scenic = [Scenic modelWithJSON:data];
        
        if (block) {
            block(scenic,error);
        }
    }];
}
//1.9 讲解线路详情
+ (void)getLineDetailWithLinID:(NSString *)lineID block:(void (^)(LineModel * model, NSError * error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"lineinfo/%@",lineID] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        LineModel *model = [LineModel modelWithJSON:data];
        
        if (block) {
            block(model, error);
        }
        
    }];
}
//2.1 发送验证码
+ (void)getCodeWithCountryCode:(NSString *)countrycode cellPhone:(NSString *)cellPhone usage:(NSInteger)usage Block:(void (^)(NSString * result, NSError * error))block {
    
    
    NSString *url = nil;
    NSDictionary *params = nil;
    
    if (usage == 2) {
        
        url = @"v2/sendcode2";
        params = @{};
    } else {
        url = @"v2/sendcode";
        params = @{@"countrycode":countrycode,@"cellphone":cellPhone,@"usage":@(usage).stringValue};
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:url withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data,error);
        }
    }];
}
//2.2 用户手机注册
+ (void)phoneRegisterWithCountryCode:(NSString *)countrycode cellPhone:(NSString *)cellPhone encode:(NSString *) encode psw:(NSString *)psw block:(void (^)(NSString * result, NSError * error))block {
    
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionaryWithDictionary:@{@"countrycode":countrycode,@"username":cellPhone,@"encode":encode,@"password":psw}];
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"tourist" withParams:paramsDict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
            }
            
            return;
        }
        
        UserInfo *userInfo = [UserInfo modelWithJSON:data];
        
        
        [UMessage addAlias:userInfo.uid type:UMessageGroup response:nil];
        
        [UserManager sharedManager].user = userInfo;
        
        [UserManager sharedManager].token = data[@"token"];
        [NetClient changeClient];
        
        [UserManager sharedManager].loginName = cellPhone;
        [UserManager sharedManager].loginCode = countrycode;
        [SAMKeychain setPassword:psw forService:kKeychainService account:cellPhone];
        
        if (block) {
            
            block(MYLocalizedString(@"LOGIN_SUCCESS", nil),nil);
        }
    }];
}
//2.3 用户第三方注册
+ (void)thirdRegisterType:(NSDictionary *)params block:(void (^)(NSString * result, NSError * error))block {
    
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionaryWithDictionary:params];
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"tourist3rd" withParams:paramsDict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
            }
            
            return;
        }
        
        UserInfo *userInfo = [UserInfo modelWithJSON:data];
        
        
        [UMessage addAlias:userInfo.uid type:UMessageGroup response:nil];
        
        [UserManager sharedManager].user = userInfo;
        
        [UserManager sharedManager].token = data[@"token"];
        [NetClient changeClient];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:kRefreshUserNotif object:nil];
        
        if (block) {
            block(MYLocalizedString(@"LOGIN_SUCCESS", nil),nil);
        }
        
    }];
}
//2.4 用户手机登录
+ (void)phoneLoginWithCountryCode:(NSString *)countrycode cellPhone:(NSString *)cellPhone psw:(NSString *)psw block:(void (^)(NSString * result, NSError * error))block {
    
    NSDictionary *paramsDict = @{@"countrycode":countrycode,@"username":cellPhone,@"password":psw};
    [[NetClient sharedClient] requestJsonDataWithPath:@"tourist/login" withParams:paramsDict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
            }
            return;
        }
        
        UserInfo *userInfo = [UserInfo modelWithJSON:data];
        
        
        [UMessage addAlias:userInfo.uid type:UMessageGroup response:nil];
        
        [UserManager sharedManager].user = userInfo;
        
        [UserManager sharedManager].loginName = cellPhone;
        [UserManager sharedManager].loginCode = countrycode;
        [SAMKeychain setPassword:psw forService:kKeychainService account:cellPhone];
        
        
        [UserManager sharedManager].token = data[@"token"];
        [NetClient changeClient];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:kRefreshUserNotif object:nil];
        
        if (block) {
            block(MYLocalizedString(@"LOGIN_SUCCESS", nil),nil);
        }
        
    }];
}
//2.5 获取用户信息
+ (void)getUserInfoWithBlock:(void (^)(NSString * result, NSError * error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/tourist/userinfo" withParams:nil needCache:NO withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
            }
            return;
        }
        
        UserInfo *userInfo = [UserInfo modelWithJSON:data];
        
        
        [UMessage addAlias:userInfo.uid type:UMessageGroup response:nil];
        
        [UserManager sharedManager].user = userInfo;
        
        if (block) {
            block(@"ok",nil);
        }
    }];
}
//2.8 退出登录
+ (void)logoutWithBlock:(void (^)(NSString * result, NSError * error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"logout" withParams:nil needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
            }
            return;
        }
        
        [UserManager sharedManager].user = nil;
        [UserManager sharedManager].token = nil;
        
        [NetClient changeClient];
        [[NSNotificationCenter defaultCenter] postNotificationName:kRefreshUserNotif object:nil];
        if (block) {
            block(data,nil);
        }
    }];
}
//2.9 更新用户密码
+ (void)resetPswWithCountryCode:(NSString *)countrycode cellPhone:(NSString *)cellPhone psw:(NSString *)psw encode:(NSString *)encode block:(void (^)(NSString * result, NSError * error))block {
    
    NSDictionary *paramsDict = @{@"countrycode":countrycode,@"username":cellPhone,@"password":psw,@"encode":encode};
    [[NetClient sharedClient] requestJsonDataWithPath:@"userpass" withParams:paramsDict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
            }
            return;
        }
        
        [UserManager sharedManager].loginName = cellPhone;
        [UserManager sharedManager].loginCode = countrycode;
        [SAMKeychain setPassword:psw forService:kKeychainService account:cellPhone];
        
        if (block) {
            block(data,nil);
        }
    }];
}


+ (void)updateUserinfo:(id)needData type:(NSString *)type block:(void (^)(NSString * result, NSError * error))block {
    
    if ([type isEqualToString:@"headimg"]) {
        [[NetClient sharedClient] uploadImageWithImage:needData path:@"headimg" name:type progress:nil andBlock:^(id data, NSError *error) {
            
            if (error) {
                block (nil,error);
                
                return ;
            }
            
            [self getUserInfoWithBlock:^(NSString *result, NSError *error) {
                
                if (block) {
                    block(data,error);
                }
            }];
            
        }];
        return;
    }
    
    
    NSDictionary *paramsDict = @{type : needData};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/tourist/userinfo" withParams:paramsDict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            block (nil,error);
            
            return ;
        }
        
        [self getUserInfoWithBlock:^(NSString *result, NSError *error) {
            
            if (block) {
                block(data,error);
            }
        }];
    }];
}
//1.10 收藏
+ (void)collectWithType:(CollectType)collectType favourid:(NSString *)favourid block:(void (^)(id result, NSError *error))block {
    
    NSString *type = @"";
    
    switch (collectType) {
        case CollectTypeGuider:
            type = @"guider";
            break;
        case CollectTypeStrategy:
            type = @"strategy";
            break;
        case CollectTypeLine:
            type = @"customline";
            break;
        case CollectTypeAlbum:
            type = @"album";
            break;
            
        default:
            break;
    }
    
    NSDictionary *paramDict = @{@"favourtype" : type, @"favourid":favourid ? favourid : @""};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"favour" withParams:paramDict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        if (error) {
            if (block) {
                block(nil,error);
            }
            return;
        }
        if (block) {
            block(data[@"state"], error);
        }
        
    }];
}


//1.27 预下单接口

+ (void)preorderOrderWithLineID:(NSString *)lineid block:(void (^)(NSDictionary *result, NSError *error))block {
    
    NSDictionary *params = nil;
    if (lineid) {
        params = @{@"lineid":lineid};
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/preorder" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data, error);
        }
    }];
}

//1.11 支付宝支付订单
//1.12 微信支付订单
//1.13 PayPal支付订单
//1.19 苹果内购支付APPLE
+ (void)getPaymentinfoWithPaymentID:(NSString *)paymentid couponid:(NSString *)couponid orderid:(NSString *)orderid ticketmodel:(UploadTicketOrderModel *)ticketModel ordernumber:(NSString *)ordernumber payType:(PayType)payType merchType:(MerchType)merchType andBlock:(void (^)(id result, NSError *error))block {
    
    NSString *url = @"";
    switch (payType) {
            
        case PayTypeAlipay:
            url = @"v2/pay/alipay";
            break;
        case PayTypeWX:
            url = @"v2/pay/wechat";
            break;
        case PayTypePaypal:
            url = @"v2/pay/paypal";
            break;
        case PayTypeApplepay:
            url = @"v2/pay/";
            break;
        case PayTypeIAP:
            url = @"v2/pay/iap";
            break;
        case PayTypeCoin:
            url = @"v2/pay/bitcoin";
            break;
            
        default:
            break;
    }
    
    NSString *type = @"";
    switch (merchType) {
            
        case MerchTypeLine:
            type = @"line";
            break;
        case MerchTypeTicket:
            type = @"ticket";
            break;
        case MerchTypeTopup:
            type = @"topup";
            break;
            
        default:
            break;
    }
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    
    if (type) {
        [params setObject:type forKey:@"type"];
    }
    
    if (paymentid) {
        [params setObject:paymentid forKey:@"id"];
    }
    
    if (couponid) {
        [params setObject:couponid forKey:@"couponid"];
        
    }
    
    if (orderid) {
        
        [params setObject:orderid forKey:@"orderid"];
    }
    
    if (ordernumber) {
        [params setObject:ordernumber forKey:@"ordernumber"];
    }
    
    if (ticketModel) {
        
        NSArray * visitors = ticketModel.visitors;
        NSDictionary *contact = [ticketModel.contact modelToJSONObject];
        
        NSString *visitdate =[NSString stringWithFormat:@"%@%@",ticketModel.orderdate,ticketModel.APM];
        
        NSMutableDictionary *ticketDict = [NSMutableDictionary dictionary];
        
        if (visitors) {
            
            [ticketDict setObject:visitors forKey:@"visitors"];
        }
        
        if (visitdate) {
            [ticketDict setObject:visitdate forKey:@"orderdate"];
        }
        
        if (contact) {
            [ticketDict setObject:contact forKey:@"contact"];
        }
        
        NSString *ticketJson = [ticketDict modelToJSONString];
        
        if (ticketJson) {
            [params setObject:ticketJson forKey:@"detail"];
        }
    }
    
    
    [[NetClient sharedClient] requestJsonDataWithPath:url withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data,error);
        }
    }];
    
}

//1.14 验证支付宝订单是否成功
//1.16 验证微信订单是否成功
//1.18 PayPal验证
//1.20 苹果内购支付验证
+ (void)verifyPaymentOrderID:(NSString*)orderid notorderid:(NSString *)notorderid currency:(NSString *)currency payType:(PayType)payType andBlock:(void (^)(id result, NSError *error))block {
    
    NSString *url = @"";
    switch (payType) {
            
        case PayTypeAlipay:
            url = @"v2/pay/alipay/check";
            break;
        case PayTypeWX:
            url = @"v2/pay/wechat/check";
            break;
        case PayTypePaypal:
            url = @"v2/pay/paypal/check";
            break;
        case PayTypeApplepay:
            url = @"v2/pay//check";
            break;
        case PayTypeIAP:
            url = @"v2/pay/iap/check";
            
            if (notorderid.length == 0) {
                if (block) {
                    block(nil,[NSError errorWithDomain:[AppManager sharedManager].baseURLStr code:0 userInfo:@{@"msg":@"订单丢失"}]);
                    [PayDAO deletePayModelWithOrderid:orderid];
                }
                return;
            }
            
            break;
        case PayTypeCoin:
            url = @"v2/pay/bitcoin/check";
            break;
            
        default:
            break;
    }
    
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    
    if (orderid) {
        [paramsDict setObject:orderid forKey:@"orderid"];
    }
    
    if (notorderid) {
        [paramsDict setObject:notorderid forKey:@"notorderid"];
    }
    
    if (!currency) {
        currency = [AppManager sharedManager].currencyCode;
    }
    
    if (currency) {
        [paramsDict setObject:currency forKey:@"currency"];
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:url withParams:paramsDict needCache:NO withMethodType:Post autoShowError:YES retryingNumberOfTimes:@(5) andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data,error);
        }
    }];
    
}
//2.10 我的收藏
+ (void)getCollectWithType:(CollectType)collectType block:(void (^)(NSArray *resultArray, NSError *error))block {
    
    NSString * classString = @"GuiderModel";
    
    NSString *url = @"myfavour";
    switch (collectType) {
        case CollectTypeGuider:
            url = @"v2/myfavour/guider";
            break;
        case CollectTypeStrategy:
            url = @"v2/myfavour/strategy";
            classString = @"Raiders";
            break;
        case CollectTypeLine:
            url = @"v2/myfavour/customline";
            classString = @"LineModel";
            break;
        case CollectTypeAlbum:
            url = @"v2/myfavour/album";
            classString = @"LineModel";
            break;
            
        default:
            break;
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:url withParams:nil needCache:NO withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *resultArray = [NSArray modelArrayWithClass:NSClassFromString(classString) json:data];
        
        if ([classString isEqualToString:@"GuiderModel"]) {
            
            [resultArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                
                ((GuiderModel *)obj).isfavor = YES;
            }];
        }
        
        if (block) {
            block(resultArray, error);
        }
        
    }];
}

//2.11 我的订单
+ (void)getOrderStart:(NSNumber *)start count:(NSNumber *)count type:(MerchType)type Block:(void (^)(NSArray <OrderModel *>*orderArray, NSError *error))block {
    
    NSDictionary *params = @{@"pageno":start,@"pagesize":count,@"type":type == MerchTypeTicket ? @"ticket":@"line"};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/myorders" withParams:params needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *orderArray = [NSArray modelArrayWithClass:[OrderModel class] json:data[@"orders"]];
        
        if (block) {
            block(orderArray, error);
        }
        
    }];
}
//2.12 问题反馈
+ (void)feedback:(NSNumber *)type content:(NSString *)content account:(NSString *)account Block:(void (^)(NSString *result, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"advice" withParams:@{@"type":type,@"content":content, @"account":account} needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data, error);
        }
        
    }];
}
//2.13 用户评价
+ (void)evaluate:(NSString *)unionid isLine:(BOOL)isLine score:(NSNumber *)score comment:(NSString *)comment Block:(void (^)(NSString *result, NSError *error))block {
    
    NSString *url = @"v2/comment";
    
    if (isLine) {
        url = @"grade";
    }
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    
    if (unionid) {
        [params setObject:unionid forKey:@"unionid"];
    }
    
    if (score) {
        [params setObject:score forKey:@"score"];
    }
    
    if (comment) {
        [params setObject:comment forKey:@"comment"];
    }
    
    
    [[NetClient sharedClient] requestJsonDataWithPath:url withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data, error);
        }
    }];
}
//2.14 我的优惠券
+ (void)getMycouponsWithLineid:(NSString *)lineid Block:(void (^)(NSArray <Coupon *>*couponArray, NSError *error))block {
    
    NSDictionary *dict = @{};
    
    if (lineid.length > 0) {
        dict = @{@"lineid" : lineid};
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/mycoupons" withParams:dict needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *couponArray = [NSArray modelArrayWithClass:[Coupon class] json:data];
        
        if (block) {
            block(couponArray, error);
        }
        
    }];
}
//0.3 用户数据收集
+ (void)postPhoneData:(NSDictionary *)params {
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params];
    [dict setObject:kVersion forKey:@"Version"];
    [dict setObject:[[PhoneInfo shareInfo] deviceUUID] forKey:@"deriveID"];
    [dict setObject:[UserManager sharedManager].user.uid ? [UserManager sharedManager].user.uid : @"" forKey:@"userID"];
    [dict setObject:@"iOS" forKey:@"channel"];
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"behavior/da" withParams:dict needCache:NO withMethodType:Post autoShowError:NO andBlock:nil];
}
//2.15 兑换优惠券
+ (void)redeemCouponCode:(NSString *)code Block:(void (^)(NSArray <Coupon *>*couponArray, NSString *errmsg))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"redeem/v2" withParams:@{@"code":code} needCache:NO withMethodType:Post autoShowError:NO andBlock:^(id data, NSError *error) {
        
        NSString *errmsg = [IGUtil tipFromError:error];
        
        if ([errmsg isEqualToString:@"noredeem"]) {
            
            errmsg = MYLocalizedString(@"VOUCHER_ERROR_CODE_INVALID", nil);
        } else if ([errmsg isEqualToString:@"used"]) {
            
            errmsg = MYLocalizedString(@"VOUCHER_ERROR_CODE_USED", nil);
        } else if ([errmsg isEqualToString:@"notrmb"]) {
            
            errmsg = MYLocalizedString(@"VOUCHER_ERROR_CODE_INVALID", nil);
        }
        
        NSArray *couponArray = [NSArray modelArrayWithClass:[Coupon class] json:data];
        
        if (block) {
            block(couponArray, errmsg);
        }
    }];
}

//2.16 优惠券跳转
+ (void)useCouponid:(NSString *)couponid Block:(void (^)(NSString *lineid, NSString *errmsg))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"usecoupon/%@",couponid] withParams:@{} needCache:NO withMethodType:Post autoShowError:NO andBlock:^(id data, NSError *error) {
        
        NSString *errmsg = [IGUtil tipFromError:error];
        
        if ([errmsg isEqualToString:@"noredeem"]) {
            
            errmsg = MYLocalizedString(@"VOUCHER_ERROR_CODE_INVALID", nil);
        } else if ([errmsg isEqualToString:@"used"]) {
            
            errmsg = MYLocalizedString(@"VOUCHER_ERROR_CODE_USED", nil);
        } else if ([errmsg isEqualToString:@"notrmb"]) {
            
            errmsg = MYLocalizedString(@"VOUCHER_ERROR_CODE_INVALID", nil);
        }
        
        if (block) {
            block(data[@"lineid"], errmsg);
        }
    }];
}

//2.16.1 线路的提问列表
+ (void)getAllQuestionsWithLineID:(NSString *)lineid pageno:(NSNumber *)pageno pigesize:(NSNumber *)pagesize Block:(void (^)(NSDictionary * guiderInfo, NSArray <Question *>*questionArray, NSError *error))block {
    
    NSMutableDictionary *parmas = [[NSMutableDictionary alloc] initWithDictionary:@{@"pageno":pageno,@"pagesize":pagesize}];
    
    if (lineid) {
        [parmas setObject:lineid forKey:@"lineid"];
    }
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"qa/page/lineqa" withParams:parmas needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *questionArray = [NSArray modelArrayWithClass:[Question class] json:data[@"content"]];
        
        if (block) {
            block(data,questionArray, error);
        }
        
    }];
}
//2.16.2 我的提问列表
+ (void)getMyQuestionBlock:(void (^)(NSArray <Question *>*questionArray, NSError *error))block {
    NSDictionary *parmas = @{@"pageno":@(0),@"pagesize":@(1000)};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"qa/page/myqa" withParams:parmas needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *questionArray = [NSArray modelArrayWithClass:[Question class] json:data[@"content"]];
        
        if (block) {
            block(questionArray, error);
        }
        
    }];
    
}
//1.23 讲解线路全部评论
+ (void)getAllCommentsWithLineID:(NSString *)lineid isLine:(BOOL)isLine Block:(void (^)(NSArray<Comment *> *, LineModel *, NSError *))block {
    
    NSString *url = [NSString stringWithFormat:@"v2/alumb/%@/comments",lineid];
    
    if (isLine) {
        url = [NSString stringWithFormat:@"line/%@/comments",lineid];
    }
    
    NSDictionary *parmas = @{@"pageno":@(0),@"pagesize":@(1000)};
    [[NetClient sharedClient] requestJsonDataWithPath:url withParams:parmas needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        LineModel * linemodel = [LineModel modelWithJSON:data];
        
        NSArray *questionArray = [NSArray modelArrayWithClass:[Comment class] json:data[@"content"]];
        
        
        if (block) {
            block(questionArray,linemodel,error);
        }
        
    }];
}

// ------------
//0.4 获取七牛的token

+ (void)getQiniuTokenBlock:(void (^)(NSString *token, NSError * error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"qiniu/token" withParams:nil needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        if (block) {
            block(data,error);
        }
    }];
}

//上传多张图片
+ (void)uploadImages:(NSArray *)imageArray Block:(void (^)(NSArray *keys, NSError *error))block {
    
    NSString *endpoint = @"http://oss-cn-hangzhou.aliyuncs.com";
    NSString *accesskey = @"LTAIPyl3fGvKL79j";
    NSString *accesssecret = @"OejQ9cQcUzJI3Ftjy9tyLi79maQBWD";
    NSString *bucket = @"resource-imguider";
    
    
    id<OSSCredentialProvider> credential = [[OSSPlainTextAKSKPairCredentialProvider alloc] initWithPlainTextAccessKey:accesskey secretKey:accesssecret];
    
    OSSClient *client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credential];
    
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    queue.maxConcurrentOperationCount = imageArray.count;
    
    NSMutableArray *callBackNames = [NSMutableArray array];
    
    for (UIImage *image in imageArray) {
        
        if (image) {
            
            NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
                //任务执行
                OSSPutObjectRequest *put = [OSSPutObjectRequest new];
                put.bucketName = bucket;
                long timeName = [NSDate date].timeIntervalSince1970 * 1000;
                NSString *uid = [UserManager sharedManager].user.uid ? [UserManager sharedManager].user.uid : [NSUUID UUID].UUIDString;
                NSString *imageName = [NSString stringWithFormat: @"upload/images/%@/%ld.jpg",uid,timeName];
                put.objectKey = imageName;
                [callBackNames addObject:imageName];
                NSData *data = UIImageJPEGRepresentation([IGUtil fixOrientation:image], 0.5);
                put.uploadingData = data;
                
                OSSTask * putTask = [client putObject:put];
                [putTask waitUntilFinished]; // 阻塞直到上传完成
                
                if (putTask.error) {
                    
                    if (block) {
                        block(nil,putTask.error);
                    }
                }
                if (image == imageArray.lastObject) {
                    
                    if (block) {
                        block([NSArray arrayWithArray:callBackNames],nil);
                    }
                }
            }];
            if (queue.operations.count != 0) {
                [operation addDependency:queue.operations.lastObject];
            }
            [queue addOperation:operation];
        }
    }
    
}

//2.17 提问QA
+ (void)qaWithLineid:(NSString *)lineid question:(NSString *)question images:(NSArray *)imageArray Block:(void (^)(id data, NSError *error))block {
    
    [self uploadImages:imageArray Block:^(NSArray *keys, NSError *error) {
        
        if (error) {
            if (block) {
                block(nil,error);
                
            }
            return ;
        }
        
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:@{@"lineid":lineid,@"question":question ,@"qtype":@(1)}];
        
        if (keys.count > 0) {
            
            NSMutableString *keysStr = [NSMutableString string];
            for (NSString *key in keys) {
                
                if (key) {
                    [keysStr appendString:key];
                }
                
                if (![key isEqualToString:keys.lastObject]) {
                    [keysStr appendString:@","];
                }
            }
            
            [params setObject:keysStr forKey:@"pictures"];
        }
        
        [[NetClient sharedClient] requestJsonDataWithPath:@"qa/add" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
            
            if (block) {
                block(data,error);
            }
        }];
    }];
}
//1.25 是否购买过该线路
+ (void)getLineBoughtStateWithLineid:(NSString *)lineid Block:(void (^)(LineModel *model, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[@"hasbought" stringByAppendingPathComponent:lineid] withParams:@{} needCache:NO withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        LineModel *model = [LineModel modelWithJSON:data];
        
        if (block) {
            block(model,error);
        }
    }];
}
//3.1.1 游客-攻略列表
+ (void)getRaidersBy:(NSNumber *)cityID start:(NSNumber *)start count:(NSNumber *)count block:(void (^)(NSArray *, NSError *))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"strategy/page?pageno=%@&pagesize=%@",start,count] withParams:@{@"city":cityID,@"type":@(1),@"status":@(2)} needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *raidersArray = [NSArray modelArrayWithClass:[Raiders class] json:data[@"content"]];
        
        if (block) {
            block (raidersArray, error);
        }
        
    }];
    
}

//1.24 所有签约行家
+ (void)getAllGuidersBlock:(void (^)(NSArray *, NSError *))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"vipguiders" withParams:@{} needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *guiderArray = [NSArray modelArrayWithClass:[GuiderModel class] json:data[@"content"]];
        
        if (block) {
            block (guiderArray, error);
        }
    }];
}

//2.19 提问回复是否已读
+ (void)setMessgaeReadWithQid:(NSString *)qid Block:(void (^)(NSString *result, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"qa/%@/isread",qid] withParams:@{} needCache:YES withMethodType:Post autoShowError:NO andBlock:^(id data, NSError *error) {
        
        if (block) {
            block (data, error);
        }
    }];
}
//3.2.1 游客-统计点击次数
+ (void)clickCountWithID:(NSString *)relationid type:(NSString *)type {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"clickcount/add" withParams:@{@"relationid":relationid, @"type":type} needCache:NO withMethodType:Post autoShowError:NO andBlock:nil];
}


//---------------------------------V2--------------------------------------

+ (void)getHomePageWithBlock:(void (^)(HomeModel *model, NSError *error))block {
    
    
//    CLLocationCoordinate2D coor = transformFromGCJToWGS([LocationManager sharedManager].currentLocation.coordinate, nil);
//    
//    NSDictionary *params = @{@"lng": @(coor.longitude),@"lat":@(coor.latitude)};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        HomeModel *model = [HomeModel modelWithJSON:data];
        
        if (block) {
            block(model,error);
        }
        
    }];
}

+ (void)getMoreLinesWithBlock:(void (^)(NSArray <LineModel *>*linesArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/customlines" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *linesArray = [NSArray modelArrayWithClass:[LineModel class] json:data[@"lines"]];
        
        if (block) {
            block(linesArray,error);
        }
    }];
}

+ (void)getMoreCitiesWithBlock:(void (^)(NSArray <City *>*citiesArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/cities" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *citiesArray = [NSArray modelArrayWithClass:[City class] json:data[@"cities"]];
        
        if (block) {
            block(citiesArray,error);
        }
    }];
}

+ (void)getMoreAlbumsWithBlock:(void (^)(NSArray <LineModel *>*albumsArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/albums" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *albumsArray = [NSArray modelArrayWithClass:[LineModel class] json:data[@"lines"]];
        
        if (block) {
            block(albumsArray,error);
        }
    }];
}

+ (void)getMoreCitysWithBlock:(void (^)(NSArray <City *>*citiesArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/cities" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *citiesArray = [NSArray modelArrayWithClass:[City class] json:data[@"cities"]];
        
        if (block) {
            block(citiesArray,error);
        }
    }];
}

//v2_BWCX - 1.04 目的地首页

+ (void)getCityDetail:(NSString *)cid block:(void (^)(City *city, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/city/%@",cid] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        City *city = [City modelWithJSON:data];
        
        if (block) {
            block(city,error);
        }
    }];
}

+ (void)getPaylistBlock:(void (^)(NSArray <ChargeCoinModel *>*paylistArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/paylist" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *paylistArray = [NSArray modelArrayWithClass:[ChargeCoinModel class] json:data];
        
        if (block) {
            block(paylistArray,error);
        }
    }];
}

+ (void)updatepsw:(NSString *)password code:(NSString *)encode block:(void (^)(NSString *result, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/tourist/password" withParams:@{@"encode":encode, @"password":password} needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block (data,error);
        }
    }];
}

+ (void)updateCellphoneWithCountryCode:(NSString *)countrycode cellPhone:(NSString *)cellPhone encode:(NSString *)encode PassWord:(NSString *)password block:(void (^)(NSString * result, NSError * error))block {
    
    NSDictionary *params = @{@"countrycode":countrycode,@"cellphone":cellPhone,@"encode":encode,@"password":password};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/tourist/mobile" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (error) {
            block(nil,error);
            return ;
        }
        
        [self getUserInfoWithBlock:^(NSString *result, NSError *error) {
            
            if (block) {
                block(data,error);
            }
        }];
    }];
}


+ (void)getExpenseCalendarListWithPageno:(NSInteger)pageno pagesize:(NSInteger)pagesize Block:(void (^)(NSArray <ExpenseModel *>*expenselistArray, NSError *error))block {
    
    NSDictionary *params = @{@"pageno":@(pageno),@"pagesize":@(pagesize)};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/myconsumes" withParams:params needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *expenselistArray = [NSArray modelArrayWithClass:[ExpenseModel class] json:data[@"content"]];
        
        if (block) {
            block(expenselistArray,error);
        }
    }];
}

+ (void)getMessagesListWithPageno:(NSInteger)pageno pagesize:(NSInteger)pagesize Block:(void (^)(NSArray <Message *>*listArray, NSError *error))block {
    
    NSDictionary *params = @{@"pageno":@(pageno),@"pagesize":@(pagesize)};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/mymessages" withParams:params needCache:YES withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        
        NSArray *listArray = [NSArray modelArrayWithClass:[Message class] json:data[@"content"]];
        
        if (block) {
            block(listArray,error);
        }
    }];
}

+ (void)getSearchResultWithKeyWords:(NSString *)keyWords block:(void (^)(NSArray *, NSError *))block{
    
    NSDictionary *params = @{@"key":keyWords};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/search" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray * resultArray = [NSArray modelArrayWithClass:[SearchResultModel class] json:data];
        if (block) {
            block(resultArray,error);
        }
    }];
}


+ (void)getRewardMessageWithLineid:(NSString *)lineid block:(void (^)(RewardMsgModel *model, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/reward/%@",lineid] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        RewardMsgModel *model = [RewardMsgModel modelWithJSON:data];
        
        if (block) {
            block(model, error);
        }
    }];
}

+ (void)rewardWithLineid:(NSString *)lineid coin:(NSString *)coin block:(void (^)(NSString *result, NSError *error))block {
    
    NSDictionary *params = @{@"lineid":lineid,@"reward":coin};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/reward" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        if (block) {
            block(data,error);
        }
    }];
}

+ (void)getRewardRecordListWithUnionid:(NSString *)unionid block:(void (^)(NSArray *resultArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/rewardlist/%@",unionid] withParams:@{} needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray * resultArray = [NSArray modelArrayWithClass:[RewardRecordModel class] json:data];
        
        if (block) {
            block(resultArray, error);
        }
    }];
}


+ (void)getTicketListWithCityID:(NSString *)cityID block:(void (^)(NSArray *, NSError *))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/ticketlist/%@",cityID] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray * ticketList = [NSArray modelArrayWithClass:[TicketModel class] json:data];
        
        if (block) {
            block(ticketList,error);
        }
    }];
}

+ (void)getTicketDetailWithTicketID:(NSString *)ticketID block:(void (^)(TicketDetailModel *, NSError *))block{
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/ticket/%@",ticketID] withParams:nil needCache:NO withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        TicketDetailModel * ticketDetailModel = [TicketDetailModel modelWithJSON:data];
        
        if (block) {
            block(ticketDetailModel,error);
        }
    }];
}


+ (void)addTravelerInformationWith:(TicketMemberInfoModel *)travelerModel block:(void (^)(TicketMemberInfoModel *, NSError *))block{
    NSString * idstr =@"";
    if (travelerModel.ID) {
        idstr = travelerModel.ID;
    }
    NSDictionary *params = @{@"realname":travelerModel.realname,@"firstname":travelerModel.firstname,@"lastname":travelerModel.lastname,@"birthday":travelerModel.birthday,@"passportno":travelerModel.passportno,@"passportcountry":travelerModel.passportcountry,@"id":idstr};
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/visitor" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        TicketMemberInfoModel * model = [TicketMemberInfoModel modelWithJSON:data];
        if (block) {
            block(model,error);
        }
    }];
}


+ (void)getTravelerListBlock:(void (^)(NSArray *, NSError *))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/visitors"] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray * travelerList = [NSArray modelArrayWithClass:[TicketMemberInfoModel class] json:data];
        
        if (block) {
            block(travelerList,error);
        }
    }];
}

+ (void)scanWithParams:(NSDictionary *)params block:(void (^) (id result, NSError *error)) block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/qrscan" withParams:params needCache:NO withMethodType:Post autoShowError:NO andBlock:^(id data, NSError *error) {
        
        if (block) {
            block (data,error);
        }
    }];
}

+ (void)listenRecordWithNodeid:(NSString *)nodeid {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/alumbnode/%@",nodeid] withParams:nil needCache:NO withMethodType:Get autoShowError:NO andBlock:nil];
}

+ (void)getTicketOrderRecordDetailWith:(NSString *)orderID block:(void (^)(UploadTicketOrderModel *, NSError *))block {
    
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/ticketorder/%@",orderID] withParams:nil needCache:NO withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        UploadTicketOrderModel * model = [UploadTicketOrderModel modelWithJSON:data];
        
        if (block) {
            block(model,error);
        }
    }];
}



+ (void)getCompeleteTicketOrderBlock:(void (^)(NSArray *, NSError *))block {
    
    NSDictionary * params = @{@"pageno":@"0",@"pagesize":@"999"};
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/mytickets" withParams:params needCache:NO withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray * ticketsArray = [NSArray modelArrayWithClass:[UploadTicketOrderModel class] json:data[@"content"]];
        
        
        if (block) {
            block(ticketsArray,error);
        }
    }];
}

+ (void)getRateListWithBlock:(void (^)(NSArray *rateArray, NSError *error))block {
    
    [[NetClient sharedClient] requestJsonDataWithPath:@"v2/homepage/forex" withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *rateArray = [NSArray modelArrayWithClass:[RateMode class] json:data];
        
        if (block) {
            block(rateArray,error);
        }
    }];
}

//
+ (void)getAllBusinessWithCityid:(NSString *)cityid block:(void (^)(NSArray *businessArray, NSError *error))block  {
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/city/%@/business",cityid] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        NSArray *bArray = [NSArray modelArrayWithClass:[MerchantModel class] json:data];
        
        if (block) {
            block(bArray,error);
        }
    }];
}

+ (void)getBusinessDetailID:(NSString *)bid type:(NSString *)type block:(void (^)(MerchantModel *model, NSError *error))block {
    
    
    [[NetClient sharedClient] requestJsonDataWithPath:[NSString stringWithFormat:@"v2/business/%@/%@",type,bid] withParams:nil needCache:YES withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        
        MerchantModel *model = [MerchantModel modelWithJSON:data];
        
        if (block) {
            block(model,error);
        }
    }];
}
@end


